
#include "WiseTask.h"
#include "../Timer/Timer.h"

using namespace ttg::devices;
using namespace ttg_internal::services;
using namespace ttg::services;

//----------------
//--- WiseTask ---
//----------------

WiseTask::WiseTask(double expected_time)
{
	t_expected = expected_time;
	t_start = 0.0;
	t_elapsed = 0.0;
}

void WiseTask::perform(std::vector<ttg::threads::Task *> &produced_tasks)
{
	//Starting.
	t_start = Timer::getRef()->getSeconds();
	//Executing.
	task_kernels[selected_device]->invoke();
	//Finishing.
	t_elapsed = Timer::getRef()->getSeconds() - t_start;
	on_finish.notify(this);
}

WiseTask::~WiseTask()
{
	std::vector<ttg::structures::InvokableObject *> objects;
	SAFE_DELETE_CONTENT(&task_kernels.toVector());
	task_kernels.clear();
}
